/**
 * 
 */
package edu.sjtu.seda.stage;

import edu.sjtu.seda.event.EventHandler;
import edu.sjtu.seda.event.EventHandlerImpl;

/**
 * @author john.zhu
 *
 */
public class StageImpl implements Stage {
	private String name;
	private StageWrapper stageWrapper;
	private EventHandler handler;
	private Stage nextStage;
	
	public StageImpl(String name,EventHandler handler,StageConfig config){
		this.name = name;
		this.handler = handler;
		this.stageWrapper = new StageWrapperImpl(this,handler,config);
	}
	
	public StageImpl(String name){
		this(name,new EventHandlerImpl(),new StageConfigImpl());
	}
	
	public StageImpl(String name,EventHandler handler){
		this(name,handler,new StageConfigImpl());
	}

	/* (non-Javadoc)
	 * @see edu.sjtu.seda.stage.Stage#getName()
	 */
	@Override
	public String getName() {
		return this.name;
	}

	/* (non-Javadoc)
	 * @see edu.sjtu.seda.stage.Stage#getStageWrapper()
	 */
	@Override
	public StageWrapper getStageWrapper() {
		return this.stageWrapper;
	}

	@Override
	public void destroy() {
		this.stageWrapper.destroy();
	}

	@Override
	public Stage getNextStage() {
		return this.nextStage;
	}

	@Override
	public void start() {
		this.stageWrapper.start();
	}

}
